package com.example.njupt.log;

import kotlin.text.Regex;
import timber.log.Timber;

import static com.example.njupt.constant.LogConstants.BOTTOM_BORDER;
import static com.example.njupt.constant.LogConstants.LEFT_BORDER;
import static com.example.njupt.constant.LogConstants.LINE_SEP;
import static com.example.njupt.constant.LogConstants.MIDDLE_BORDER;
import static com.example.njupt.constant.LogConstants.TOP_BORDER;

/**
 * Author:      mwang
 * Create Date: Created in 2021/5/27 20:07
 * Update Date:
 * Modified By:
 * Description:
 */
public class DebugTree extends Timber.DebugTree {
    @Override
    protected void log(int priority, String tag, String message, Throwable t) {
        for (String it : message.split(String.valueOf(new Regex(LINE_SEP)))) {
            switch (it) {
                case TOP_BORDER:
                case BOTTOM_BORDER:
                case MIDDLE_BORDER:
                    super.log(priority, tag, it, t);
                    break;
                case "":
                    break;
                default:
                    super.log(priority, tag, LEFT_BORDER + it, t);
            }
        }
    }
}
